﻿using System;
using RootMotion.FinalIK;
using UnityEngine;

namespace RootMotion.Demos
{
	// Token: 0x020000C9 RID: 201
	[RequireComponent(typeof(FullBodyBipedIK))]
	public class FixFeet : MonoBehaviour
	{
		// Token: 0x06000602 RID: 1538 RVA: 0x00005D88 File Offset: 0x00003F88
		public void Start()
		{
			this.ik = base.GetComponent<FullBodyBipedIK>();
			this.Sample();
		}

		// Token: 0x06000603 RID: 1539 RVA: 0x00037CB0 File Offset: 0x00035EB0
		public void Sample()
		{
			this.relativePosL = base.transform.InverseTransformPoint(this.ik.solver.leftFootEffector.bone.position);
			this.relativePosR = base.transform.InverseTransformPoint(this.ik.solver.rightFootEffector.bone.position);
			this.relativeRotL = Quaternion.Inverse(base.transform.rotation) * this.ik.solver.leftFootEffector.bone.rotation;
			this.relativeRotR = Quaternion.Inverse(base.transform.rotation) * this.ik.solver.rightFootEffector.bone.rotation;
		}

		// Token: 0x06000604 RID: 1540 RVA: 0x00037D80 File Offset: 0x00035F80
		public void LateUpdate()
		{
			if (this.weight <= 0f)
			{
				return;
			}
			this.ik.solver.leftFootEffector.positionOffset = (base.transform.TransformPoint(this.relativePosL) - this.ik.solver.leftFootEffector.bone.position) * this.weight;
			this.ik.solver.rightFootEffector.positionOffset = (base.transform.TransformPoint(this.relativePosR) - this.ik.solver.rightFootEffector.bone.position) * this.weight;
			this.ik.solver.leftFootEffector.bone.rotation = Quaternion.Lerp(this.ik.solver.leftFootEffector.bone.rotation, base.transform.rotation * this.relativeRotL, this.weight);
			this.ik.solver.rightFootEffector.bone.rotation = Quaternion.Lerp(this.ik.solver.rightFootEffector.bone.rotation, base.transform.rotation * this.relativeRotR, this.weight);
		}

		// Token: 0x04000510 RID: 1296
		[Range(0f, 1f)]
		public float weight = 1f;

		// Token: 0x04000511 RID: 1297
		public FullBodyBipedIK ik;

		// Token: 0x04000512 RID: 1298
		public Vector3 relativePosL;

		// Token: 0x04000513 RID: 1299
		public Vector3 relativePosR;

		// Token: 0x04000514 RID: 1300
		public Quaternion relativeRotL;

		// Token: 0x04000515 RID: 1301
		public Quaternion relativeRotR;
	}
}
